package com.msh.starter.qrcode.config;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties("msh.starter.qrcode")
public class QrCodeProperties {

  private int width = 300;
  private int height = 300;
  private String format = "png";
  private BarcodeFormat codeType = BarcodeFormat.QR_CODE;
  private ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;

  public int getWidth() {
    return width;
  }

  public QrCodeProperties setWidth(int width) {
    this.width = width;
    return this;
  }

  public int getHeight() {
    return height;
  }

  public QrCodeProperties setHeight(int height) {
    this.height = height;
    return this;
  }

  public BarcodeFormat getCodeType() {
    return codeType;
  }

  public QrCodeProperties setCodeType(BarcodeFormat codeType) {
    this.codeType = codeType;
    return this;
  }

  public String getFormat() {
    return format;
  }

  public QrCodeProperties setFormat(String format) {
    this.format = format;
    return this;
  }

  public ErrorCorrectionLevel getErrorCorrectionLevel() {
    return errorCorrectionLevel;
  }

  public QrCodeProperties setErrorCorrectionLevel(int level) {
    this.errorCorrectionLevel = ErrorCorrectionLevel.forBits(level);
    return this;
  }
}
